<template>
  <div>
    <h1>{{ newsDetail.title }}</h1>
    <p>{{ newsDetail.content }}</p>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { getNewsDetailAPI } from '@/api/news'

const route = useRoute()
const newsDetail = ref({})

onMounted(async () => {
  const newsId = route.params.id
  try {
    const response = await getNewsDetailAPI(newsId)
    newsDetail.value = response.data
  } catch (error) {
    console.error('获取新闻详情失败:', error)
  }
})
</script>

<style scoped>
/* 可以添加样式 */
</style>
